﻿

function main() {
    showLog("抖音(推荐评论)");
    var testVersion = "(201901021555)版";
    var softwareName = "抖音";
    var view = RequestEngine.getWebView();
    var viewJson = JSON.parse(view);
    var search = viewJson.search;
    var contentArr = viewJson.contentArr;
    AccessibilityEngine.sleepEngine(5000);//等待
    if (AccessibilityEngine.checkUpId(widget.pages.shouye.bugengxin) == ISTRUE) { //更新以后再说
        AccessibilityEngine.mockOnClickId(widget.pages.shouye.bugengxin);
    }
    if (AccessibilityEngine.checkUpId(widget.pages.shouye.wzdl) == ISTRUE) { //我知道了
        AccessibilityEngine.mockOnClickId(widget.pages.shouye.wzdl);
    }
     AccessibilityEngine.sleepEngine(2000);//等待
    var jixing = getXYByIdIndex(widget.pages.shouye.wode);
    ScreenEngine.swipe(parseX(300), parseY(1000), parseX(300), parseY(200), 500); //从下往上滑动
    if (AccessibilityEngine.checkUpId(widget.pages.shouye.bugengxin) == ISTRUE) { //更新以后再说
        AccessibilityEngine.mockOnClickId(widget.pages.shouye.bugengxin);
    }
    showLog("jixing"+jixing);
    for (var i =0 ; i <search; i ++ ){  //滑动
        if (AccessibilityEngine.checkUpId(widget.pages.shouye.bugengxin) == ISTRUE) { //更新以后再说
            AccessibilityEngine.mockOnClickId(widget.pages.shouye.bugengxin);
        }
       AccessibilityEngine.sleepEngine(5000);//等待
	   
       if( jixing == 1 ){
           var pressjixing = "press," + parseX(660) + "," + parseY(763);
           ScreenEngine.currency(pressjixing);
       } else if( jixing == 2 ){
           ScreenEngine.swipe(parseX(667), parseY(760), parseX(667), parseY(760), 500); 
       }

       if (AccessibilityEngine.checkUpId(widget.pages.shouye.pinglunKuang) == ISTRUE){
		   if (AccessibilityEngine.checkUpId(widget.pages.shouye.bugengxin) == ISTRUE) { //更新以后再说
				AccessibilityEngine.mockOnClickId(widget.pages.shouye.bugengxin);
			}
           AccessibilityEngine.mockOnClickId(widget.pages.shouye.pinglunKuang); // 点击评论
           AccessibilityEngine.sleepEngine(5000);//等待
           var search2 = contentArr[Math.floor(Math.random()*contentArr.length)];
           AccessibilityEngine.mockEditId(widget.pages.shouye.pinglunKuang, search2); //赋值
           AccessibilityEngine.mockOnClickId(widget.pages.shouye.fasong); // 发送
           if (AccessibilityEngine.getEditText(widget.pages.shouye.pinglunKuang)==search2){
               AccessibilityEngine.mockBack();
           }
           if (AccessibilityEngine.getEditText(widget.pages.shouye.pinglunKuang)==search2){
               AccessibilityEngine.mockBack();
           }
           AccessibilityEngine.sleepEngine(1000);//等待
           if ( AccessibilityEngine.checkUpId(widget.pages.shouye.pinglunKuang) == ISTRUE){
               showLog("点击返回");
               AccessibilityEngine.mockBack();
           }
           if ( AccessibilityEngine.checkUpId(widget.pages.shouye.pinglunKuang) == ISTRUE){
               showLog("点击返回");
               AccessibilityEngine.mockBack();
           }
       }
       if (i>=search-1){
           showLog("执行成功");
           setTaskState("5", "脚本执行完毕");
           throw SyntaxError();
       }
        AccessibilityEngine.sleepEngine(2000);//等待
        showLog("滑动");
        ScreenEngine.swipe(parseX(300), parseY(1000), parseX(300), parseY(200), 1500); //从下往上滑动
		
    }
    showLog("显示执行成功");
    setTaskState("5", "脚本执行完毕");
    throw SyntaxError();

}
var publicfunction = RequestEngine.getPluginPath() + "OS_DYCOMMON/publicfunction.js";
include(publicfunction); //公共方法js
var widgetPath = dyConditionCheck();
var widgetbyid = RequestEngine.getPluginPath() +"OS_DYCOMMON/"+ widgetPath;
include(widgetbyid);
main();